<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .main {
        	background-color: #fff;
        }
        .main ul li .li_box {
        	display: -webkit-box;
        	display: -webkit-flex;
        	padding: 15px;
        	border-bottom: 1px solid #e8e8e8;
        }
        .main ul li .li_box .li_boxl .li_img {
			width: 43px;
			height: 43px;
			border-radius: 50%;
			overflow: hidden;
        }
        .main ul li .li_box .li_boxl .li_img img {
        	width: 100%;
        	height: 100%;
        	object-fit: cover;
        }
        .main ul li .li_box .li_boxr {
        	flex: 1;
        	-webkit-flex: 1;
        	box-flex: 1;
        	-webkit-box-flex: 1;
        	padding-left: 6px;
        }
        .main ul li .li_box .li_boxr .name {
        	font-size: 14px;
        	color: #333;
        	margin-bottom: 8px;
        }
        .main ul li .li_box .li_boxr .evaluate {
        	font-size: 12px;
        	color: #999;
        	display: -webkit-box;
        	-webkit-box-align: center;
        	margin-bottom: 15px;
        }
        .main ul li .li_box .li_boxr .evaluate .evaluate_good {
        	color: #ffa82c;
        	display: block;
        }
        .main ul li .li_box .li_boxr .evaluate .evaluate_bad {
        	color: #999;
        	display: block;
        }
        .main ul li .li_box .li_boxr .evaluate img {
        	height: 12px;
        	margin-left: 3px;
        	display: block;
        }
        .main ul li .li_box .li_boxr .evaluate_content {
			font-size: 14px;
			color: #333;
        }
        .loading{
            color: #ccc;
            text-align: center;
            line-height: 25px;
            display: none;
        }
        .without_data{
            display: none;
            color:#ccc;
            text-align:center;
            padding-top: 15px;
        }
        .hidden_img {
            display: none;
        }
    </style>
</head>
<body>
    <div class="main">
    	<ul id="comment_ul">
<!--     		<li>
    			<div class="li_box">
    				<div class="li_boxl">
    					<div class="li_img">
    						<img src="../image/temp/1.png">
    					</div>
    				</div>
    				<div class="li_boxr">
    					<div class="name">用户昵称</div>
						<div class="evaluate">商品： <span class="evaluate_good">好评</span><img src="../image/evaluate_good.png"></div>
						<div class="evaluate_content">很好吃</div>
    				</div>
    			</div>
    		</li> -->

    	</ul>
        <div class="loading">loading...</div>

    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="commentTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li>
            <div class="li_box">
                <div class="li_boxl">
                    <div class="li_img">
                        <img src="{{=formatVideoImg(it[i]['img'])}}">
                    </div>
                </div>
                <div class="li_boxr">
                    <div class="name">{{=it[i]['nickname']}}</div>
                    <div class="evaluate">
                        商品： 
                        {{if(it[i]['opinion'] == 1){ }}
                            <span class="evaluate_good">好评</span><img src="../image/evaluate_good.png">
                        {{ }else{ }}
                            <span class="evaluate_bad">差评</span><img src="../image/evaluate_bad.png">

                        {{ }; }}
                    </div>
                    <div class="evaluate_content">{{=it[i]['content']}}</div>
                    {{ if(it[i]['pictures']){ }}
                        <div class="goods_img_box">
                            {{for(var j=0;j<it[i]['pictures'].length;j++){ }}
                                <div class="goods_img">
                                    <img src="{{=formatVideoImg(it[i]['pictures'][j]['img'])}}">
                                </div>
                            {{ }; }}
                        </div>
                    {{ }; }}
                </div>
            </div>
        </li>
    {{ }; }}
</script>
<script type="text/javascript">
    apiready = function(){
        goods_id = api.pageParam.goods_id;
        p = 1;
        canLoad = true;
        fnGetComment();
        //上拉加载
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:0            //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){
            if(canLoad) {
                p++;
                if($(window).scrollTop()) {
                    $(".loading").show();
                }
                fnGetComment(2);
            }
        });

        //下拉刷新
        api.setCustomRefreshHeaderInfo({
            bgColor: '#f8f8f8',
            loadAnimInterval:60,
            image: {
               pull: pullArr,
               load: loadArr
            }
        }, function(ret, err) {
            canLoad = true;
            p = 1;
            fnGetComment(1);
        });
    };

    function fnGetComment(type) {
        if(canLoad == false) {
            return;
        }
        canLoad = false;
        api.ajax({
            url: rootPath+'/api/shop/get_comment',
            method: 'post',
            data: {
                values: { 
                    goods_id: goods_id,
                    page_num :10,
                    p:p
                },

            }
        }, function(ret, err) {
           if(type == 1) {
                $('#comment_ul').empty();
            }
            if (ret) {
                if(ret.status == 200) {
                    $('.without_data').hide();
                    $('.all_evaluate').show();
                    appendDotData(ret.data,'commentTpl','comment_ul',true,false);
                }
                if(ret.count >= 10) {
                    canLoad == true;
                }
            } else {
                api.toast({
                    msg: err.msg,
                    location : 'middle'
                });
            }
            if(type == 1) {
                // 是下拉刷新的，要收回
                api.refreshHeaderLoadDone();
            }
            if(type == 2) {
                //上拉给点假时间,好看些         
                setTimeout(function(){
                    $(".loading").hide();
                },1000);
            }else {
                $('.loading').hide();
            }
            closeLoading();
        });
    }
</script>
</html>